-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework iio_context_get_xml() #1133
Conversation
@@ -300,6 +301,7 @@ class ChannelType(Enum): | |||
_iiolib = "iio" | |||
|
|||
_lib = _cdll("libiio.so.1", use_errno=True, use_last_error=True) | |||
_libc = _cdll(find_library("c")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail in Windows. Need to use something like ctypes.util.find_msvcrt
Probably need to fix the _cdll call above as well since that breaks Windows too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Python bindings were broken on Windows before, and they are still broken on Windows after, then I'd argue it's not a problem of this commit and it can be fixed later in a subsequent PR. I'm kind of running against time here :)
Instead of returning a string allocated alongside the IIO context, it will now return a string allocated on the heap, that has to be freed with free() afterwards. The function can now also return errors. The advantage of this change is multiple: - IIO contexts now don't have a huge XML string allocated during their whole lifetime; - If the application does not call iio_context_get_xml(), then all the internal functions used to generate the XML string in the first place are dead code, and when building statically, can be garbage-collected. Signed-off-by: Paul Cercueil <[email protected]>
Emulate the v0.x behaviour of iio_context_get_xml() by allocating the XML string when the Libiio context is created; which means that the compatibility layer's iio_context_get_xml() is still a "pure" function. Signed-off-by: Paul Cercueil <[email protected]>
Now that iio_context_get_xml() returns a heap-allocated string, we need to de-allocate it with free() after use. Signed-off-by: Paul Cercueil <[email protected]>
78e06b9
to
37f3bf8
Compare
Now that iio_context_get_xml() returns a heap-allocated string, we need to de-allocate it with free() after use. Signed-off-by: Paul Cercueil <[email protected]>
Now that iio_context_get_xml() returns a heap-allocated string, we need to de-allocate it with free() after use. Signed-off-by: Paul Cercueil <[email protected]>
Now that iio_context_get_xml() returns a heap-allocated string, we need to de-allocate it with free() after use. Signed-off-by: Paul Cercueil <[email protected]>
37f3bf8
to
79ffd4c
Compare
Instead of returning a string allocated alongside the IIO context, it
will now return a string allocated on the heap, that has to be freed
with free() afterwards. The function can now also return errors.
The advantage of this change is multiple:
whole lifetime;
internal functions used to generate the XML string in the first place
are dead code, and when building statically, can be garbage-collected.
C# bindings will be updated by @AlexandraTrifan in #1122.